package com.linesum.code.design.Observer;

/**
* 
* @author chenzf
* @date 2017年8月1日
*/
@SuppressWarnings("unused")
public class CurrentConditionsDisplay implements Observer, DisplayElement {
	private Double temperature;
	private Double humidity;
	private Subject subject;

	public CurrentConditionsDisplay(Subject subject) {
		this.subject = subject;
		subject.registerObserver(this);
	}

	@Override
	public void display() {
		System.out.printf("当前温度:%s,当前湿度:%s\n", temperature, humidity);
	}

	@SuppressWarnings("hiding")
	@Override
	public void update(Double temp, Double humidity, Double pressure) {
		setTemperature(temp);
		setHumidity(humidity);
		display();
	}

	public Double getTemperature() {
		return temperature;
	}

	public void setTemperature(Double temperature) {
		this.temperature = temperature;
	}

	public Double getHumidity() {
		return humidity;
	}

	public void setHumidity(Double humidity) {
		this.humidity = humidity;
	}

}
